package com.lv.suyiyong.hfr.adapter

import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import com.blankj.utilcode.util.SizeUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.lv.common.base.DataBindBaseViewHolder
import com.lv.common.imp.OnPositionTListener
import com.lv.common.ktx.LoadSrc
import com.lv.service.bean.ViewTypeBean
import com.lv.suyiyong.hfr.R
import com.lv.suyiyong.hfr.databinding.ItemMediaBinding

/**
 * 作者： ygx
 * 创建日期：2022/6/24 8:10 PM
 * 签名： 天行健，君子以自强不息；地势坤，君子以厚德载物。
 *      _              _           _     _   ____  _             _ _
 *     / \   _ __   __| |_ __ ___ (_) __| | / ___|| |_ _   _  __| (_) ___
 *    / _ \ | '_ \ / _` | '__/ _ \| |/ _` | \___ \| __| | | |/ _` | |/ _ \
 *   / ___ \| | | | (_| | | | (_) | | (_| |  ___) | |_| |_| | (_| | | (_) |
 *  /_/   \_\_| |_|\__,_|_|  \___/|_|\__,_| |____/ \__|\__,_|\__,_|_|\___/
 *
 * You never know what you can do until you try !
 * ----------------------------------------------------------------
 *
 */
class MediaTypeNoPlayAdapter(
    private val datas: MutableList<ViewTypeBean>?,
    private val mHeigth: Float = 173.0f
) :
    BaseQuickAdapter<ViewTypeBean, DataBindBaseViewHolder>
        (R.layout.item_media, datas) {

    override fun convert(holder: DataBindBaseViewHolder, item: ViewTypeBean) {
        val mBinding: ItemMediaBinding =
            holder.getBind() as ItemMediaBinding
//        mBinding.itemRoot = item
//        //防止列表闪烁
        mBinding.executePendingBindings()
        val layoutPosition = holder.layoutPosition
        mBinding.ivPic.LoadSrc(item.data.imageFirst)
        mBinding.ivPic.setOnClickListener {
            onViewItemClickListener?.onClick(layoutPosition, item)
        }

        val layoutParams = mBinding.ivPic.layoutParams as ConstraintLayout.LayoutParams
        layoutParams.height = SizeUtils.dp2px(mHeigth)
        mBinding.ivPic.layoutParams = layoutParams
        mBinding.ivTag.visibility =
            if (item.type == ViewTypeBean.VEDIO_TYPE) View.VISIBLE else View.GONE
//        clParent.setOnClickListener { onViewItemClickListener?.onClick(layoutPosition, item) }

    }

    var onViewItemClickListener: OnPositionTListener<ViewTypeBean>? = null

}